This XFCN will copy all files and folders from sourcePath to destinationPath. The hidden feature of this XFCN is that the destination path does not have to exist in order for the copy to be successful. As long as the volume name at the beginning of the path is correct, HFSCopy will automatically create all folders it needs. Each new folder will be set to resemble the parent folder. In other words, a new folder will have the same view, color, etc. as the parent folder. The only difference is that the window of the new folder will be staggered down and to the right of the parent. This is useful if you want to automatically copy selected files off of one drive while maintaining their relative heirarchy and not have to worry about empty folders. Just create a destination folder (not necessary if you are copying to the root of a volume), set up the window so it looks nice, and call the XFCN! I have not found any upper limit to the number of files/folders this will copy. We have successfully used it to copy 550MB consisting of over 4,000 files and 6 levels deep.
PLEASE NOTE: This XFCN copies folders a bit differently than most other XCMD's available now. After testing it a bit, I think you will find this to be a more powerful implementation. If you call HFSCopy("myHD:Folder1:","yourHD:"), all of the files in Folder1 will be put at the root level of yourHD. A folder called "Folder1" WILL NOT be created on the destination drive. In order to copy all source files into a folder with the same name as the source use:
This will create an exact copy of Folder1 from "MyHD" in "FolderA" of "YourHD". By using the destination path for the CONTENTS of the source path and not the source path itself, the XFCN allows you to rename the destination folder.
Other examples:
HFSCopy("myHD:", "yourHD:") -- clone your HD
HFSCopy("myHD:accounts","OverThere:tempFile") -- copy and rename a file
Parameter 1: The source PATH for the copy. Can be a path to a file or folder.
Parameter 2: The destination PATH for the copy. Must be the same type as the source path. The destination path can be any legal path. No one folder name can be greater than 32 characters. If the specified path does not exist, it will be created (i.e. if the destination is 'MyHD:Destination:somefile' and the folder 'Destination:' does not exist, it will be created. Volumes can not be created!) If a single file is being copied, the destination filename can be any valid filename, the copy that is made will have the filename specified in the destination.
'?' as the first parameter will return the syntax of this XCMD.
'!' as the first parameter will return the copyright and version information.
'NoDialog' can be passed as the last parameter to suppress any messages from being sent via HyperCard's answer dialog. Error messages will be sent back in the result or in the global specified if the last parameter is of the form: 'NoDialog:globalvarname'
Result:
Line 1 will be a count of the files/folders copied.
Line 2 will be an error message or empty if no error occured